<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @author Walter Tamboer
 * @package Framework03
 */

/**
 * The base class for all database statements.
 */
abstract class FW_Database_Statement_Abstract
{
    /**
     * @var string The name of the table to truncate.
     */
    private $tableName;
    
    /**
     * Initializes a new instance of this class.
     * @param FW_Database_Table $table The table to use in this statement.
     */
    abstract public function __construct(FW_Database_Table $table);
    
    /**
     * Sets the name of the table to execute this statement on.
     * @param string|FW_Database_Table $table The table to set.
     * @return FW_Database_Statement_Abstract
     */
    public function setTableName($table)
    {
        if ($table instanceof FW_Database_Table)
            $this->tableName = $table->getTableName();
        else if (is_string($table))
            $this->tableName = $table;
        else
            throw new FW_Database_Exception('Table should be a string or a FW_Database_Table object.', 500);
    }
    
    /**
     * Gets the name of the table.
     * @return string
     */
    public function getTableName()
    {
        return $this->tableName;
    }
}
